ga.view.streaming
Class StreamingEvaluationState<T extends IIndividual<T>>

java.lang.Object
  extended by com.jme3.app.state.AbstractAppState
      extended by ga.view.appstate.RootNodeState
          extended by ga.view.appstate.SceneState
              extended by ga.view.streaming.StreamingEvaluationState<T>
Type Parameters:
T - The generic type of the individuals.
All Implemented Interfaces:
com.jme3.app.state.AppState, IFitnessEvaluator<T>, IInteractiveFitnessEvaluator<T>, IMenuListenerParent

public class StreamingEvaluationState<T extends IIndividual<T>>
extends SceneState
implements IInteractiveFitnessEvaluator<T>, IMenuListenerParent

This interactive evaluator provides a stream of pictures of the show room. There are 2 zones to upvote/downvote the individuals.

Since:
12.08.2012
Author:
Stephan Dreyer

Nested Class Summary
private  class StreamingEvaluationState.DragListener
          This is a mouse listener that detects drag-and-drop.
private  class StreamingEvaluationState.ViewSwitchListener
          Keyboard listener to switch the perspective.
 
Field Summary
private  ISIGA<T> algorithm
           
private  java.util.List<AnchorNode<T>> anchorNodes
           
private  com.jme3.app.Application app
           
private  com.jme3.bullet.BulletAppState bulletAppState
           
private  CameraSettings camSettings
           
private  StreamingEvaluationState.DragListener dragListener
           
private  boolean enabled
           
private  java.util.List<EvaluationListener<T>> listeners
           
private static java.util.logging.Logger LOGGER
           
private  EvaluationNode lowerBox
           
private  MenuListener menuListener
           
private  boolean mouseDown
           
private static float PANEL_SPACING
           
private  com.jme3.scene.Node panelsNode
           
private  IPhenotypeGenerator<T,? extends com.jme3.scene.Spatial> phenotypeGenerator
           
private  com.jme3.scene.Geometry pointer
           
private  com.jme3.bullet.control.RigidBodyControl pointerControl
           
static float SCENE_WIDTH
           
private  com.jme3.system.AppSettings settings
           
private  ShowRoomFactory showRoomFactory
           
private  ShowRoomState<T> showRoomState
           
private  float speed
           
private  ShowRoomSettings srSettings
           
private  EvaluationNode upperBox
           
 
Fields inherited from class ga.view.appstate.SceneState
assetManager, cam, inputManager, renderManager, stateManager, timer, viewPort
 
Fields inherited from class ga.view.appstate.RootNodeState
rootNode
 
Fields inherited from class com.jme3.app.state.AbstractAppState
initialized
 
Constructor Summary
StreamingEvaluationState(IPhenotypeGenerator<T,? extends com.jme3.scene.Spatial> phenotypeGenerator)
          Instantiates a new streaming evaluation state.
 
Method Summary
 void addEvaluationListener(EvaluationListener<T> listener)
          Adds an EvaluationListener that will be notified about the evaluation state.
 void cleanup()
           
private  void createPanel(T individual)
          Creates a panel for an individual.
 void evaluate(T individual)
          Evaluates the given individual.
private  com.jme3.collision.CollisionResults findPick(com.jme3.scene.Node node)
          Finds spatials in the scene that has been clicked.
 void fireIndividualEvaluated(T individual)
          Notification method that causes all EvaluationListeners being notified that the evaluator has evaluated the individual.
 void fireNewIndividualRequested()
          Notification method that causes all EvaluationListeners being notified that the evaluator demands a new individual for evaluation.
 ISIGA<T> getAlgorithm()
          Getter for the interactive genetic algorithm.
private  com.jme3.bullet.PhysicsSpace getPhysicsSpace()
          Gets the physics space.
private  void initCam()
          Inits the cam.
 void initialize(com.jme3.app.state.AppStateManager stateManager, com.jme3.app.Application app)
           
private  void initPointer()
          Inits the pointer.
private  void initTable()
          Make a solid floor and add it to the scene.
private  void removeAnchorNode(AnchorNode<T> anchorNode)
          This is called when the anchorNode goes out of the screen without being evaluated.
 void removeEvaluationListener(EvaluationListener<T> listener)
          Adds an EvaluationListener.
private  void removePanel(PanelNode<T> panelNode)
          Removes a panel from the scene.
 void setAlgorithm(ISIGA<T> algorithm)
          Sets the interactive genetic algorithm.
 void setEnabled(boolean enabled)
           
 void setMenuListener(MenuListener menuListener)
          Sets the menu listener.
private  void showInShowRoom(PanelNode<T> panelNode)
          Shows a panel node in show room.
 void update(float tpf)
           
 
Methods inherited from class ga.view.appstate.SceneState
finalCleanUp, getCamera
 
Methods inherited from class ga.view.appstate.RootNodeState
getRootNode
 
Methods inherited from class com.jme3.app.state.AbstractAppState
isEnabled, isInitialized, postRender, render, stateAttached, stateDetached
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCENE_WIDTH

public static final float SCENE_WIDTH
See Also:
Constant Field Values

PANEL_SPACING

private static final float PANEL_SPACING
See Also:
Constant Field Values

LOGGER

private static final java.util.logging.Logger LOGGER

pointer

private com.jme3.scene.Geometry pointer

mouseDown

private boolean mouseDown

pointerControl

private com.jme3.bullet.control.RigidBodyControl pointerControl

panelsNode

private com.jme3.scene.Node panelsNode

phenotypeGenerator

private final IPhenotypeGenerator<T extends IIndividual<T>,? extends com.jme3.scene.Spatial> phenotypeGenerator

showRoomFactory

private ShowRoomFactory showRoomFactory

srSettings

private final ShowRoomSettings srSettings

bulletAppState

private final com.jme3.bullet.BulletAppState bulletAppState

showRoomState

private ShowRoomState<T extends IIndividual<T>> showRoomState

lowerBox

private EvaluationNode lowerBox

upperBox

private EvaluationNode upperBox

anchorNodes

private final java.util.List<AnchorNode<T extends IIndividual<T>>> anchorNodes

listeners

private final java.util.List<EvaluationListener<T extends IIndividual<T>>> listeners

dragListener

private final StreamingEvaluationState.DragListener dragListener

camSettings

private CameraSettings camSettings

menuListener

private MenuListener menuListener

settings

private com.jme3.system.AppSettings settings

speed

private float speed

enabled

private boolean enabled

algorithm

private ISIGA<T extends IIndividual<T>> algorithm

app

private com.jme3.app.Application app
Constructor Detail

StreamingEvaluationState

public StreamingEvaluationState(IPhenotypeGenerator<T,? extends com.jme3.scene.Spatial> phenotypeGenerator)
Instantiates a new streaming evaluation state.

Parameters:
phenotypeGenerator - the phenotype generator
Since:
12.08.2012
Method Detail

setMenuListener

public void setMenuListener(MenuListener menuListener)
Description copied from interface: IMenuListenerParent
Sets the menu listener.

Specified by:
setMenuListener in interface IMenuListenerParent
Parameters:
menuListener - the new menu listener

initialize

public void initialize(com.jme3.app.state.AppStateManager stateManager,
                       com.jme3.app.Application app)
Specified by:
initialize in interface com.jme3.app.state.AppState
Overrides:
initialize in class SceneState

cleanup

public void cleanup()
Specified by:
cleanup in interface com.jme3.app.state.AppState
Overrides:
cleanup in class RootNodeState

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface com.jme3.app.state.AppState
Overrides:
setEnabled in class SceneState

update

public void update(float tpf)
Specified by:
update in interface com.jme3.app.state.AppState
Overrides:
update in class RootNodeState

initCam

private void initCam()
Inits the cam.

Since:
12.08.2012

initTable

private void initTable()
Make a solid floor and add it to the scene.


initPointer

private void initPointer()
Inits the pointer. A red ball that marks the last spot that was "hit" by the "shot".

Since:
12.08.2012

findPick

private com.jme3.collision.CollisionResults findPick(com.jme3.scene.Node node)
Finds spatials in the scene that has been clicked.

Parameters:
node - The parent node to check for clicks.
Returns:
The results of the click.
Since:
12.08.2012

getPhysicsSpace

private com.jme3.bullet.PhysicsSpace getPhysicsSpace()
Gets the physics space.

Returns:
the physics space
Since:
12.08.2012

setAlgorithm

public void setAlgorithm(ISIGA<T> algorithm)
Description copied from interface: IInteractiveFitnessEvaluator
Sets the interactive genetic algorithm.

Specified by:
setAlgorithm in interface IInteractiveFitnessEvaluator<T extends IIndividual<T>>
Parameters:
algorithm - The SIGA.

getAlgorithm

public ISIGA<T> getAlgorithm()
Description copied from interface: IInteractiveFitnessEvaluator
Getter for the interactive genetic algorithm.

Specified by:
getAlgorithm in interface IInteractiveFitnessEvaluator<T extends IIndividual<T>>
Returns:
The SIGA.

showInShowRoom

private void showInShowRoom(PanelNode<T> panelNode)
Shows a panel node in show room.

Parameters:
panelNode - the panel node
Since:
12.08.2012

createPanel

private void createPanel(T individual)
Creates a panel for an individual.

Parameters:
individual - the individual
Since:
12.08.2012

removeAnchorNode

private void removeAnchorNode(AnchorNode<T> anchorNode)
This is called when the anchorNode goes out of the screen without being evaluated.

Parameters:
anchorNode - The anchor node that leaves the screen

removePanel

private void removePanel(PanelNode<T> panelNode)
Removes a panel from the scene.

Parameters:
panelNode - the panel node
Since:
12.08.2012

fireNewIndividualRequested

public void fireNewIndividualRequested()
Description copied from interface: IInteractiveFitnessEvaluator
Notification method that causes all EvaluationListeners being notified that the evaluator demands a new individual for evaluation.

Specified by:
fireNewIndividualRequested in interface IInteractiveFitnessEvaluator<T extends IIndividual<T>>

fireIndividualEvaluated

public void fireIndividualEvaluated(T individual)
Description copied from interface: IInteractiveFitnessEvaluator
Notification method that causes all EvaluationListeners being notified that the evaluator has evaluated the individual.

Specified by:
fireIndividualEvaluated in interface IInteractiveFitnessEvaluator<T extends IIndividual<T>>
Parameters:
individual - The evaluated individual.

addEvaluationListener

public void addEvaluationListener(EvaluationListener<T> listener)
Description copied from interface: IInteractiveFitnessEvaluator
Adds an EvaluationListener that will be notified about the evaluation state.

Specified by:
addEvaluationListener in interface IInteractiveFitnessEvaluator<T extends IIndividual<T>>
Parameters:
listener - The listener.

removeEvaluationListener

public void removeEvaluationListener(EvaluationListener<T> listener)
Description copied from interface: IInteractiveFitnessEvaluator
Adds an EvaluationListener.

Specified by:
removeEvaluationListener in interface IInteractiveFitnessEvaluator<T extends IIndividual<T>>
Parameters:
listener - The listener.

evaluate

public void evaluate(T individual)
Description copied from interface: IFitnessEvaluator
Evaluates the given individual.

Specified by:
evaluate in interface IFitnessEvaluator<T extends IIndividual<T>>
Specified by:
evaluate in interface IInteractiveFitnessEvaluator<T extends IIndividual<T>>
Parameters:
individual - Individual to evaluate.